package cn.com.taurus.controller.major;

import cn.com.taurus.bean.FundManagerWebBean;
import cn.com.taurus.biz.FundManagerWebBeanBiz;
import cn.com.taurus.controller.user.MyPurseController;
import cn.com.taurus.entity.Fund;
import cn.com.taurus.impl.FundManagerWebBeanImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class FundManagerWebController {

    @Autowired
    FundManagerWebBeanBiz fundManagerWebBeanBiz;
    @Autowired
    MyPurseController myPurseController;

    @RequestMapping(value = "/Anonymous/fundManagerWeb")
    public ModelAndView fundManagerWeb(String fmId){
        ModelAndView modelAndView = new ModelAndView();
        FundManagerWebBean fundManagerWebBean = fundManagerWebBeanBiz.selectFundManagerWebBeanById(fmId);
        fundManagerWebBean.setManagerFundCount(fundManagerWebBeanBiz.selectManagerFundCountById(fmId));
        fundManagerWebBean.setFirstOffice(fundManagerWebBean.getFirstOffice().split(" ")[0]);

        List<Fund> fundData = fundManagerWebBeanBiz.selectFundById(fmId);

        modelAndView.setViewName("major/fundManager");
        modelAndView.addObject("fundManager",fundManagerWebBean);
        modelAndView.addObject("fundData",fundData);
        modelAndView.addObject("myPurseData",myPurseController.getMyPurseWebBean());
        return modelAndView;
    }

}
